﻿using RestSharp;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2.Tools
{
    class RequestTools
    {
        public string SendRequest(string file_name)
        {
            var client = new RestClient(ConfigurationManager.AppSettings["remote_url"]);
            //client.Timeout = -1;
            var request = new RestRequest();
            request.Method = Method.Post;
            //client.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
            request.AddHeader("Accept", "*/*");
            request.AddHeader("Host", "localhost:8000");
            request.AddHeader("Connection", "keep-alive");
            request.AddHeader("Content-Type", "multipart/form-data; boundary=--------------------------497471070752046375567036");
            //request.AddFile("file", "C:\\git\\PythonTools\\opencv4\\images\\Table6.jpg");
            request.AddFile("file", file_name);
            RestResponse response = client.Execute(request);
            //Console.WriteLine(response.Content);

            return response.Content;
        }


        public string GetName(string file_name)
        {
            var client = new RestClient("http://10.10.10.89:8089/api/tr-run/");
            //client.Timeout = -1;
            var request = new RestRequest();
            request.Method = Method.Post;
            //client.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
            request.AddFile("file", file_name);
            RestResponse response = client.Execute(request);

            return response.Content;
        }
    }
}
